package com.kmproject.haifu.mvp.ui.adapter;

import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HouseInfoTitleBean;
import com.library.flowlayout.FlowLayoutManager;
import com.library.flowlayout.SpaceItemDecoration;

import java.util.List;

public class HousePublicAdapter  extends BaseQuickAdapter<HouseInfoTitleBean,BaseViewHolder> {
    public HousePublicAdapter(@Nullable List<HouseInfoTitleBean> data) {
        super(R.layout.housepublic_item,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HouseInfoTitleBean item) {
         helper.<TextView>getView(R.id.housepublic_item_tv).setText(item.getTitleName());
//        helper.<RecyclerView>getView(R.id.housepublic_item_RecyclerView).setLayoutManager(new FlowLayoutManager());
        helper.<RecyclerView>getView(R.id.housepublic_item_RecyclerView).addItemDecoration(new SpaceItemDecoration(dp2px(2)));
//        FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
                helper.<RecyclerView>getView(R.id.housepublic_item_RecyclerView).setLayoutManager(new GridLayoutManager(mContext,3));
//        ArmsUtils.configRecyclerView(helper.<RecyclerView>getView(R.id.housepublic_item_RecyclerView),flowLayoutManager);

        helper.<RecyclerView>getView(R.id.housepublic_item_RecyclerView).setAdapter(new HousePublicItemAdapter(item.getChileds()));
    }
    public  int dp2px(float dpValue) {
        return (int) (0.5f + dpValue * Resources.getSystem().getDisplayMetrics().density);
    }
}
